<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link href="/static/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="/static/static/h-ui.admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="/static/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script><![endif]-->
<title>添加客需</title>
<style type="text/css">
li{margin:20px 0;}
ul li:nth-child(4){margin-top:40px;}
</style>
</head>
<body>
<div class="pd-20">

  <form action="" method="post" class="form form-horizontal" id="form-article-add">
    <ul>
      <li>用户名: <input type="text" class="input-text" name="vname" placeholder="用户名" required></li>
      <li>手机号 :<input type="text" class="input-text" name="tel" value='' placeholder="" required></li>
      <li>区域 :<select name="prov" id="prov" class='select' style='width:150px'></select>
          <select name="area" id="area" class='select' style='width:150px'><option value=''>请选择区/县</option></select>
          <select name="vill" id="vill" class='select' style='width:150px'><option value=''>请选择小区</option></select></li>
      <li><button class="btn btn-primary radius" id="submit" type="submit"><i class="Hui-iconfont">&#xe600; 添加客需</a></li>
    </ul>
  </form>
</div>
{include file='public/footer'}
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
  <script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript">
  $().ready(function(){
    $('form').validate({
      submitHandler:function(form){
        $(form).ajaxSubmit({
          type:'post',
          url:'{:url('member_add')}',
          dataType:'text',
          success:function(res){
            res = eval('('+res+')');
            layer.msg(res.msg,{icon: 1,time:1000},function(){
              location.reload();
            });
          }
        })
      }
    });
  })

   //地区三级联动
  $(function(){
    $.ajax({
        type:'post',
        url:'{:url('vill_show')}',
        data:'pid=0',
        dataType:'json',
        success:function(res){
            var str = '<option>请选择城市</option>';
            $.each(res.msg,function(key,val){
                str += '<option value='+val.id+'>'+val.name+'</option>';
            })
            $('#prov').html(str);
        }
    });
    $('select[name=prov]').change(function(){
        getData($('select[name=prov]'));
        getData($('select[name=area]'));
    });
    $('select[name=area]').change(function(){
        getData($('select[name=area]'));
    });
})
  function getData(obj){
        var val = $(obj).val();
        $.ajax({
            type:'post',
            url:'{:url('vill_show')}',
            data:'pid='+val,
            async:false,
            dataType:'json',
            success:function(res){
                var str = '';
                $.each(res.msg,function(key,val){
                    str += '<option value='+val.id+'>'+val.name+'</option>';
                });
                $(obj).next().html(str);
            }

        });
    }
</script>